package org.ezplatform.office.questionnaire.dao;
 
import java.util.List;

import org.ezplatform.core.dao.jpa.JpaBaseDao;
import org.ezplatform.office.questionnaire.entity.QuestionnaireTopic;
import org.ezplatform.office.questionnaire.entity.QuestionnaireTopicOptions;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

@Repository("questionnaireTopicOptionsDao")
public interface QuestionnaireTopicOptionsDao extends JpaBaseDao<QuestionnaireTopicOptions,String>{
	
	@Modifying
	@Query(nativeQuery = true, value = "delete from   oa_questionnaire_topic_options where topic_id in (?1)")
	int deleteOptionsByTopicId(List<String> list);
	
	@Query("from QuestionnaireTopicOptions  where   topicId = ?1 order by optionOrder")
	List<QuestionnaireTopicOptions> getOptionsByTopicId(String topicId );
	
	@Query("from QuestionnaireTopicOptions  where topicId in (select oqt.id from QuestionnaireTopic oqt where oqt.questionnaireId =?1) order by optionOrder")
	List<QuestionnaireTopicOptions> getOptionsByQuesIdAndOrder(String quesId );
	
	@Query("from QuestionnaireTopicOptions  where topicId in (select oqt.id from QuestionnaireTopic oqt where oqt.questionnaireId =?1)")
	List<QuestionnaireTopicOptions> getOptionsByQuesId(String quesId );
	
}
